package homework;

//Calculator Class
public class Calculator {
        
        //Addiction Operation for 3 values
        public int sum(int a, int b, int c){
                return (a + b + c);
        }
        
        //Substration Operation for 3 values
        public int minus(int a, int b, int c){
                return (a - b - c);
        }
        
        //Multiplication Operation for 3 values
        public int times(int a, int b, int c){
                return (a * b * c);
        }
        
        //Division Operation for 3 values
        public int divide(int a, int b, int c){
                int result = a/b;
                result = result/c;
                return result;
        }
        
        //Average Operation for 3 values
        public int average(int a, int b, int c){
                int sum = a+b+c; //Sum operation
                int result = sum/3; //Average calculation
                return result;
        }
        
        //Finding Maximum Value Operation for 3 values
        public int max(int a, int b, int c){
                int max = a; //max Variable
                
                //Value comparison
                if(max<a){
                        max = a;
                }
                if(max<b){
                        max = b;
                }
                if(max<c){
                        max = c;
                }
                return max;
        }
        //Finding Minimum Value Operation for 3 values
        public int min(int a, int b, int c){
                int min = a; //min Variable
                
                //Value comparison
                if(min>a){
                        min = a;
                }
                if(min>b){
                        min = b;
                }
                if(min>c){
                        min = c;
                }
                return min;
        }
        
        //Power Operation for 2 values
        public int power(int a, int b){
                int i; //Aux Variable
                int result; //Power Variable
                
                for(i=0,result=1;i<b;i++){
                        result = result * a; //iteration method
                }
                return result;
        }
        
        //Finding Median Value Operation for 3 values
        public int median(int a, int b, int c){
                int median = 0; //Median Variable
                int max = 0;
                int min = 0;
                
                //Finding Maximum
                max = max(a,b,c);
                
                //Finding Minimum
                min = min(a,b,c);
                
                //Comparison between values
                if (a != max && a !=min){
                        median = a;
                }
                if (b != max && b !=min){
                        median = b;
                }
                if (c != max && c !=min){
                        median = c;
                }
                return median;
        }
        
        //Finding Range Value Operation for 3 values
        public int range(int a, int b, int c){
                int range = 0; //range Variable
                int max = max(a,b,c);
                int min = min(a,b,c);
                
                //range operation (max-min)
                range = max-min;
                return range;
        }
}
